# Use the official PaddlePaddle image as the base image
FROM dockerio.int.repositories.cloud.sap/python:3.12

RUN apt-get update && apt-get install -y python3-opencv
# Install dependencies required by PaddleOCR
RUN python -m pip install --upgrade pip

# Copy only the requirements.txt file to the container
COPY requirements.txt /app/requirements.txt

# Install Python dependencies required by the application
RUN pip install --trusted-host pypi.python.org -r /app/requirements.txt

# Copy the application code to the /app directory inside the container
COPY . /app
WORKDIR /app

# Create a directory to save images
RUN cd /app && mkdir uploads

RUN python scripts/download_paddleocr_models.py 

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV LANG=C.UTF-8

# Expose the port used by the application
EXPOSE 5001

# Run the application
CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:5001", "--timeout", "180", "main:app"]